Skip to content

Conversation

@aadeshps-mcw
Copy link
Contributor

No description provided.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:parser labels Jul 22, 2025
@aadeshps-mcw aadeshps-mcw changed the title --Fix for issue #127426 [FLANG] Fix for issue #127426 Jul 22, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 22, 2025

@llvm/pr-subscribers-flang-parser

Author: Aadesh Premkumar (aadeshps-mcw)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/150006.diff

3 Files Affected:

  • (modified) flang/lib/Parser/prescan.cpp (+1)
  • (added) flang/test/Parser/inc.h (+4)
  • (added) flang/test/Parser/test.F (+14)
diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 3a9a475c365ee..ceb3d91c216cc 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -435,6 +435,7 @@ void Prescanner::LabelField(TokenSequence &token) {
   int outCol{1};
   const char *start{at_};
   std::optional<int> badColumn;
+  SkipCComments();
   for (; *at_ != '\n' && column_ <= 6; ++at_) {
     if (*at_ == '\t') {
       ++at_;
diff --git a/flang/test/Parser/inc.h b/flang/test/Parser/inc.h
new file mode 100644
index 0000000000000..a754bfbbbc641
--- /dev/null
+++ b/flang/test/Parser/inc.h
@@ -0,0 +1,4 @@
+/* Old style C comments
+*comments
+*/
+#define VAL 1
diff --git a/flang/test/Parser/test.F b/flang/test/Parser/test.F
new file mode 100644
index 0000000000000..94436d70faa05
--- /dev/null
+++ b/flang/test/Parser/test.F
@@ -0,0 +1,14 @@
+! RUN: %flang_fc1 -fdebug-unparse-no-sema %s 2>&1 | FileCheck %s
+ 
+!CHECK: SUBROUTINE foo
+!CHECK: INTEGER i
+!CHECK: i = 1
+!CHECK: PRINT *, i
+!CHECK: END SUBROUTINE foo
+ 
+      subroutine foo ()
+#include "inc.h"
+       integer :: i
+        i = VAL
+        print *,i
+      end subroutine foo

@github-actions
Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- flang/test/Parser/inc.h flang/lib/Parser/prescan.cpp
View the diff from clang-format here.
diff --git a/flang/test/Parser/inc.h b/flang/test/Parser/inc.h
index a754bfbbb..15eb75b25 100644
--- a/flang/test/Parser/inc.h
+++ b/flang/test/Parser/inc.h
@@ -1,4 +1,4 @@
 /* Old style C comments
-*comments
-*/
+ *comments
+ */
 #define VAL 1

@aadeshps-mcw aadeshps-mcw deleted the issue-1 branch July 22, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:parser flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants